<template>
  <div class="container">
    <el-form :model="formData" label-width="250px">
      <el-form-item label="社团编号:" prop="clubId">
        <el-input
          type="text"
          v-model="formData.clubId"
          disabled
          readonly
        ></el-input>
      </el-form-item>
      <!-- 添加更多个人信息字段如：电话、地址等 -->
      <el-form-item label="社团名称:" prop="clubName">
        <el-input
          type="text"
          v-model="formData.clubName"
          disabled
          readonly
        ></el-input>
      </el-form-item>
      <el-form-item label="社团介绍:" prop="introduce">
        <el-input type="textarea" v-model="formData.introduce"></el-input>
        <el-button
          type="primary"
          style="margin-top: 10px"
          @click="updateIntroduce"
          >确定</el-button
        >
      </el-form-item>
      <el-form-item label="社团类型:" prop="clubType">
        <el-input
          type="text"
          v-model="formData.clubType"
          disabled
          readonly
        ></el-input>
      </el-form-item>
      <el-form-item label="创建日期:" prop="createTime">
        <el-input
          type="text"
          v-model="formData.createTime"
          disabled
          readonly
        ></el-input>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
import request from '@/api/request'

export default {
  data() {
    return {
      formData: {
        clubId: '',
        clubName: '',
        introduce: '',
        clubType: '',
        createTime: '',
      },
    }
  },
  methods: {
    //获取社团信息
    getClubInfo() {
      request
        .get('/president/clubResult')
        .then((res) => {
          console.log(res)
          this.formData = res.data
        })
        .catch((error) => {
          this.$message.error(error)
        })
    },

    //修改社团介绍
    updateIntroduce() {
      request
        .patch('/president/updateclub', {
          introduce: this.formData.introduce,
        })
        .then((res) => {
          if (res.code === 200) {
            this.$message.success(res.message)
            setTimeout(() => {
              this.$router.go(0) // 刷新当前页面
            }, 1000)
          }
        })
        .catch((error) => {
          this.$message.error(error)
        })
    },
  },
  created() {
    this.getClubInfo()
  },
}
</script>
<style scoped>
.container {
  width: 600px;
  padding-top: 50px;
  margin-left: -10%;
}
</style>
